# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=adrdox
pkgver=2.5.4
pkgrel=1
pkgdesc='Documentation generator for D'
arch=('loong64' 'x86_64')
url='https://github.com/adamdruppe/adrdox'
license=('Boost')
depends=('postgresql-libs')
makedepends=('dmd')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha512sums=('31fe9ea840a1d55312ada785f2cba3c38b9a12b41b238a6af65d3dedcf8fb4c2d0cac1667f24e6c2ecc17a75a9fe1e981ed67435d9e1f4faa4b881042243554f')

prepare() {
    cd "$srcdir"/$pkgname-$pkgver
    # Add $LDFLAGS to the compilation, and remove -flto
    _linkflags=$(echo -ne $LDFLAGS | cut -d\" -f2 | tail -c+4 | sed -e "s/,/ -L=/g" -e "s/-flto=auto//") 
    sed -i "s/-g/-g $_linkflags/g" Makefile
}

build() {
    cd "$srcdir"/$pkgname-$pkgver

    # According to Makefile v2.5.4 "use make pq instead ldc is broken"
    # make ldc
    make pq
}

package() {
    cd "$srcdir"/$pkgname-$pkgver

    install -Dm 755 doc2 "$pkgdir"/usr/bin/$pkgname
}
